# -*- coding: utf-8 -*-

from myquerybuilder import QueryBuilder

class Mapper:
    exportFields = {}
    fieldsMapping = {}

    ptengine_import_user_id = 'ptengine.import.user_id'

    def getExportFields(self, vals):
        result = {}
        for k,v in vals.items():
            if(k in self.exportFields):
                exportField = self.exportFields[k]
                result.setdefault(exportField[0], {}).update({exportField[1] : self.getExportValue(k, v)})

        return result

    def getExportInfo(self, vals):
        return {}

    def getMappingField(self, fieldName):
        return self.fieldsMapping.get(fieldName, fieldName)

    def getExportValue(self, k, v):
        return v

    def isFromImporter(self):
        importUser = self.env['ir.config_parameter'].get_param(Mapper.ptengine_import_user_id)
        return importUser == str(self.env.user.id)

    def getExportConstraint(self, tableName):
        raise NotImplementedError